<?php

include_once($GLOBALS['cfgPaths']['lib'].'model2/SynchronizerToken.o.inc.php');

class ActionForm
{

    var $container = array();
    
    function ActionForm()
    {
        $this->container['doc_id'] = $GLOBALS['doc_id'];
    }

    function get($name)
    {
        return $this->container[$name];
    }

    function out($name)
    {
        print $this->container[$name];
    }

    function set($name, $value)
    {
        $this->container[$name] = $value;
    }
    
    function url($params, $addDocId = true)
    {
        $qs = "";
        if ($addDocId)
            $qs = "doc_id=".$GLOBALS['doc_id'];
        if (count($params)) 
        {
            $qs .= '&';
            list($n, $v) = array_pop($params);
            $qs .= $n.'='.$v; 
            foreach ($params as $n => $v)
                $qs .= "&".$n."=".urlencode($v);
        }
        $url = $GLOBALS['env']->getServer('SCRIPT_NAME');
        $url .= ($qs)?'?'.$qs:''; 
        print $url;
    }
    
    function getDocId()
    {
        return $GLOBALS['doc_id'];
    }
    
    function getDocIdHidden()
    {
        return '<input type="hidden" name="doc_id" value="'.$GLOBALS['doc_id'].'"/>';
    }
    
    function docId()
    {
        print '<input type="hidden" name="doc_id" value="'.$GLOBALS['doc_id'].'"/>';
    }
    
    function syncToken()
    {
        $st = SynchronizerToken::getInstance();
        print $st->getToken();
    }
    
    function syncTokenHidden()
    {
        $st = SynchronizerToken::getInstance();
        print $st->getHidden();
    }
    
    function keys()
    {
        return array_keys($this->container);
    }
    
    function getArray()
    {
        return $this->container;
    }
    
    function setArray($container)
    {
        if (is_array($container))
            $this->container = array_merge($this->container, $container);
    }

}

?>